/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssp;

import java.util.*;
import java.util.logging.Level;
import ssp.agent.QualityRequirement;
import ssp.database.*;
import ssp.event.*;
import ssp.utility.*;
import ssp.net.*;
import ssp.service.*;
import ssp.strategy.agent.Agent_v1_Strategy_v1;
import ssp.topology.*;

/**
 *
 * @author yamazaki
 * @version 0.0.1
 */
public class Simulation {
    
    final static String version = "0.0.2";
    
    public static void main(String args[]) {
        
        System.out.println("Simulator version=" + version);
        LoggingManager.logging(Level.INFO, "Simulator version=" + version, new Throwable());
        
        NWcomponentFactory.createNWcomponent(8);
        
        TopologyMaker.makeWSmodel(4, 0.1);
        
        EdgeManager edgeManager = EdgeManager.getINSTANCE();
        
        System.out.println("----------------");
        
        for(Edge edge : edgeManager.getEdgeList()) {
            for(Node node : edge.getConnectedNodes()) {
                System.out.print(node.toString() + " ");
            }
            System.out.println();
        }
        
        FrontendServerFactory.createFrontendServer(5, 10.0, 20.0);
        FrontendServerFactory.allocateFrontendServer();
        
        for(NWcomponent node : NWcomponentManager.getINSTANCE().getNWcomponentList()) {
            DatabaseManager.getINSTANCE().getNetworkMap().updateHopCountTable(1.0, node);
        }
        
        ServiceEntryFactory.createServiceEntry(5, 3, 3, 10);
        NWresourceFactory.allocateNWresource(3, 10);
        
        Event event = new NetworkMapUpdateEvent(1.0);
        Event event2 = new ServiceMapUpdateEvent(1.1);
        EventQueue.getINSTANCE().addEvent(event);
        EventQueue.getINSTANCE().addEvent(event2);
        for(int i=0 ; i<2 ; i++) {
            EventQueue.getINSTANCE().nextEvent();
        }
        
        List<Integer> qos = new ArrayList<Integer>();
        qos.add(0);
        qos.add(2);
        qos.add(3);
        QualityRequirement qr = new QualityRequirement(1, qos, 10, qos, 0.3);
        new Agent_v1_Strategy_v1().searchFrontendServer(qr, NWcomponentManager.getINSTANCE().getNWcomponent(1), 3);
        
    }
    
}
